package easy.netty.net.core;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
@Configuration
@ConfigurationProperties(prefix = "iocfg")
public class IoCfg {

    protected List<IoConf> ioConf = new ArrayList<>();

    public List<IoConf> getIoConf() {
        return ioConf;
    }

    public void setIoConf(List<IoConf> ioConf) {
        this.ioConf = ioConf;
    }

    public IoConf getConf(String className) {
        if (null == className || className.isEmpty())
            return null;

        for (IoConf conf : ioConf) {
            if (conf.getClassName().equalsIgnoreCase(className))
                return conf;
        }

        return null;
    }
}
